import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/cabinet/views/cabinet_form_data.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'logic.dart';

class CabinetFormPage extends StatefulWidget {
  const CabinetFormPage({Key? key}) : super(key: key);

  @override
  State<CabinetFormPage> createState() => _CabinetFormPageState();
}

class _CabinetFormPageState extends State<CabinetFormPage> {
  final CabinetFormLogic logic = Get.put(CabinetFormLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "柜机报表管理"),
      body: Stack(
        children: [
          Image.asset(MGImage.image("cabinet_back", type: ImagePathType.cabinet)),
          MGCard(
            margin: EdgeInsets.only(left: 20, right: 20, top: 200),
            padding: EdgeInsets.only(left: 16, right: 16, top: 20, bottom: 20),
            children: [
              ///报表类型
              Container(
                decoration: BoxDecoration(
                  border: Border.all(color: MGColors.splitColor, width: 1),
                  borderRadius: BorderRadius.circular(6),
                ),
                padding: EdgeInsets.only(left: 12, right: 12),
                child: Obx(() => MGItems(
                      leadTitle: logic.forms.value.isNotEmpty ? logic.forms.value : "请选择报表类型",
                      leadStyle: TextStyle(
                        color: logic.forms.value.isNotEmpty ? MGColors.text1Color : MGColors.text3Color,
                        fontSize: MGFont.textFont1,
                      ),
                      trailingIcon: MGImage.image("public_next"),
                      action: logic.selectForm,
                    )),
              ),

              /// 时间
              CabinetFormData(),

              /// 提示
              Container(
                margin: EdgeInsets.only(top: 20),
                child: Text(
                  "此数据仅供参考，实际出账以财务记录为准",
                  style: TextStyle(color: MGColors.themeColor, fontSize: MGFont.textFont3),
                ),
              ),

              /// 按钮
              MGButton(
                title: "查询",
                margin: EdgeInsets.only(top: 10),
                buttonAction: logic.queryAction,
              )
            ],
          )
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<CabinetFormLogic>();
    super.dispose();
  }
}
